package com.region.loadbalancer.policy;

import com.region.loadbalancer.group.Server;

import java.util.List;

/**
 * Load Balancing Policy
 *
 * @author liujieyu
 * @date 2023/5/24 23:33
 * @description
 */
public interface BalancerPolicy extends Cloneable {

    /**
     * <p>Select service interfaces and select different service nodes through different balancing algorithms<p/>
     * @param servers
     * @return
     */
    Server choose(List<Server> servers);

    /**
     * <p>Deep copy interface, through the implementation of the interface to copy a new object, used to serve different cluster service groups,
     * if not implemented, the current object is returned, the use of the current object may have concurrency problems.
     * You are advised to implement a deep copy interface when using a user-defined balancing policy.<p/>
     *
     * @return
     */
    default BalancerPolicy deepClone() {
        return this;
    }

}
